package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WorkPaperWinners;
import com.ruoyi.system.service.IWorkPaperWinnersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 论文完成人Controller
 * 
 * @author ruoyi
 * @date 2024-07-10
 */
@RestController
@RequestMapping("/work/winners")
public class WorkPaperWinnersController extends BaseController
{
    @Autowired
    private IWorkPaperWinnersService workPaperWinnersService;

    /**
     * 查询论文完成人列表
     */
    @PreAuthorize("@ss.hasPermi('work:winners:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkPaperWinners workPaperWinners)
    {
        startPage();
        List<WorkPaperWinners> list = workPaperWinnersService.selectWorkPaperWinnersList(workPaperWinners);
        return getDataTable(list);
    }

    /**
     * 导出论文完成人列表
     */
    @PreAuthorize("@ss.hasPermi('work:winners:export')")
    @Log(title = "论文完成人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkPaperWinners workPaperWinners)
    {
        List<WorkPaperWinners> list = workPaperWinnersService.selectWorkPaperWinnersList(workPaperWinners);
        ExcelUtil<WorkPaperWinners> util = new ExcelUtil<WorkPaperWinners>(WorkPaperWinners.class);
        util.exportExcel(response, list, "论文完成人数据");
    }

    /**
     * 获取论文完成人详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:winners:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(workPaperWinnersService.selectWorkPaperWinnersById(id));
    }

    /**
     * 新增论文完成人
     */
    @PreAuthorize("@ss.hasPermi('work:winners:add')")
    @Log(title = "论文完成人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkPaperWinners workPaperWinners)
    {
        return toAjax(workPaperWinnersService.insertWorkPaperWinners(workPaperWinners));
    }

    /**
     * 修改论文完成人
     */
    @PreAuthorize("@ss.hasPermi('work:winners:edit')")
    @Log(title = "论文完成人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkPaperWinners workPaperWinners)
    {
        return toAjax(workPaperWinnersService.updateWorkPaperWinners(workPaperWinners));
    }

    /**
     * 删除论文完成人
     */
    @PreAuthorize("@ss.hasPermi('work:winners:remove')")
    @Log(title = "论文完成人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(workPaperWinnersService.deleteWorkPaperWinnersByIds(ids));
    }
}
